import * as api from "./api";
import { CreateCrudOptionsProps, CreateCrudOptionsRet, dict } from "@fast-crud/fast-crud";
import { request } from "/@/api/service";

export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  const pageRequest = async (query) => {
    return await api.GetList();
  };
  const delRequest = async ({ row }) => {
    console.log(row);
    return await api.DelObj(row.id);
  };
  const addRequest = async ({ form }) => {
    return await api.AddObj(form);
  };
  const editRequest = async ({ form, row }) => {
    form.id = row.id;
    return await api.UpdateObj(form);
  };
  return {
    crudOptions: {
      request: {
        pageRequest,
        delRequest,
        addRequest,
        editRequest
      },
      columns: {
        id: {
          title: "ID",
          type: "number",
          column: { width: 60 },
          form: { show: false }
        },
        content: {
          title: '内容',
          key: "imgs",
          column: {
            show: true
          },
        },
        time:{
          title: '时间',
          key: "datetime",
          type:'datetime'
        }
      }
    }
  };
}
